package com.dk.springmvc.restful.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/rest")
public class RestfulController {

    @GetMapping("/user")
    public ModelAndView getAllUser() {
        ModelAndView modelAndView = new ModelAndView("successful");
        modelAndView.addObject("msg", "查询全部用户信息");
        return modelAndView;
    }

    @PostMapping("/user")
    public ModelAndView addUser() {
        ModelAndView modelAndView = new ModelAndView("successful");
        modelAndView.addObject("msg", "新增用户信息");
        return modelAndView;
    }

    @GetMapping("/user/{userId}")
    public ModelAndView getUser(@PathVariable String userId) {
        ModelAndView modelAndView = new ModelAndView("successful");
        modelAndView.addObject("msg", "查询ID为" + userId + "用户信息");
        return modelAndView;
    }

    @PutMapping("/user/{userId}")
    public ModelAndView modifyUser(@PathVariable String userId) {
        ModelAndView modelAndView = new ModelAndView("successful");
        modelAndView.addObject("msg", "修改ID为" + userId + "用户信息");
        return modelAndView;
    }

    @DeleteMapping("/user/{userId}")
    public ModelAndView removeUser(@PathVariable String userId) {
        ModelAndView modelAndView = new ModelAndView("successful");
        modelAndView.addObject("msg", "删除ID为" + userId + "用户信息");
        return modelAndView;
    }
}
